package com.zl.controller;

import com.alibaba.fastjson.JSON;
import com.zl.pojo.TSJ;
import com.zl.util.RedisUtil;
import com.zl.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import redis.clients.jedis.Jedis;
@CrossOrigin
@RestController
@RequestMapping("/zl")
public class TSJController2 {

    @GetMapping("/selectvalue")
    public Object selectValue(String key) {
        Jedis jedis = null;
        try {
            jedis = RedisUtil.getJedis();
            String value = jedis.get(key);
//            JSONObject userJson = JSONObject.parseObject(value);
//            TSJ tsj = JSON.toJavaObject(userJson,TSJ.class);
            TSJ tsj = JSON.parseObject(value, TSJ.class);
//            Object json = JSONObject.toJSON(tsj);
            return SysResult.success(tsj);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            RedisUtil.close(jedis);
        }

    }
}
